<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <!-- 
    v-model指令
    1) 作用: 实现双向数据绑定
       - 数据变化了, 视图会自动更新
       - 视图变化了, 数据也会自动更新
    2) 语法:
       v-model="表达式" 
    3) 应用场景
       - 作用于表单元素
       - 可以用于表单快速的去 设置 或 收集 数据     
   -->
  <div id="app">
    账户：<input v-model="username" type="text"> <br><br>
    密码：<input v-model="password" type="password"> <br><br>
    <button @click="login">登录</button>
    <button @click="reset">重置</button>
  </div>
  <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        username: '',
        password: ''
      },
      methods: {
        login() {
          console.log('调用登录接口', { username: this.username, password: this.password })
        },
        reset() {
          this.username = ''
          this.password = ''
        }
      },
    })
  </script>
</body>

</html>